//package com.pengzy.core.cloud_security;
//
//import com.pengzy.supports.dto.LoginUser;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.authorization.AuthorizationDecision;
//import org.springframework.security.authorization.ReactiveAuthorizationManager;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.web.server.authorization.AuthorizationContext;
//import org.springframework.stereotype.Component;
//import reactor.core.publisher.Mono;
//
//import java.util.Collection;
//
///**
// * 鉴权管理类
// * @author xiaozhi 2023/7/17
// */
//@Slf4j
//@Component
//public class AuthorizationManagers implements ReactiveAuthorizationManager<AuthorizationContext> {
//
//
//    @Override
//    public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, AuthorizationContext object) {
//        log.info("鉴权管理类");
//        return authentication.map(auth -> {
//            SecurityUserDetails userSecurity = (SecurityUserDetails) auth.getPrincipal();
//            Collection<GrantedAuthority> authorities = userSecurity.getAuthorities();
//            // TODO: 2023/7/17 角色鉴权 new AuthorizationDecision(true):代表授予权限，false拒绝权限
////            String path=object.getExchange().getRequest().getURI().getPath();
////            for (GrantedAuthority authority : auth.getAuthorities()){
////                if (authority.getAuthority().equals("ROLE_USER")&&path.contains("/user/normal"))
////                    return new AuthorizationDecision(true);
////                else if (authority.getAuthority().equals("ROLE_ADMIN")&&path.contains("/user/admin"))
////                    return new AuthorizationDecision(true);
////            //对客户端访问路径与用户角色进行匹配
////            }
//            return new AuthorizationDecision(true);
//        }).defaultIfEmpty(new AuthorizationDecision(false));
//    }
//
//}
